 <link rel="stylesheet" type="text/css" href="../../css/geological/bootstrap.css" />
<div class="modal-body">
	<form id="user-form" name="user-form" class="form-horizontal">
		<div class="box-body">
			<div class="col-md-12">
				<div class="form-group">
					<label for="old_password" class="col-sm-3 control-label">原始密码</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="old_password" name="old_password" placeholder="请输入原始密码">
					</div>
				</div>
				<div class="form-group">
					<label for="new_password" class="col-sm-3 control-label">新的密码</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="new_password" name="new_password" placeholder="请输入新的密码">
					</div>
				</div>
				<div class="form-group">
					<label for="confrim_password" class="col-sm-3 control-label">确认新密码</label>
					<div class="col-sm-8">
						<input type="text" class="form-control" id="confrim_password" name="confrim_password" placeholder="请再输入一次新的密码">
					</div>
				</div>
			</div>
		</div>
		<!-- /.box-body -->
		<div class="box-footer text-right">
			<!--以下两种方式提交验证,根据所需选择-->
			<button type="button" class="btn btn-default" data-btn-type="cancel" onclick="dialog_close()">取消操作</button>
			<button type="button" class="btn btn-primary" data-btn-type="save" onclick="save_changepwd()">修改密码</button>
		</div>
		<!-- /.box-footer -->
	</form>
</div>
<script type="text/javascript">
	$(document).ready(function(){
		
	});
	
	function checkOldPwd( fn ){
		var userinfo = {};
		userinfo.password = $("#old_password").val();
		var json_data = JSON.stringify( userinfo );
		var url = "../../tbl_user/checkpwd";
		$.ajax({
			  url: url,
			  type : 'post',
			  async : false,
			  data: json_data,
			  contentType: "application/json; charset=utf-8",
			  dataType: "json",
			  success: function(json) {
				if( json.result == "success" ){
					if(fn != null && fn != undefined ){fn();}
				}else{
					global.alert(json.message);
				}
			  }
		});
	}
	
	function save_changepwd( fn ){
		checkOldPwd( function(){
			var userinfo = {};
			userinfo.password = $("#new_password").val();
			var json_data = JSON.stringify( userinfo );
			var url = "../../tbl_user/updatepwd";
			$.ajax({
				  url: url,
				  type : 'post',
				  async : false,
				  data: json_data,
				  contentType: "application/json; charset=utf-8",
				  dataType: "json",
				  success: function(json) {
					 global.alert( json.message );
					 dialog_close();
				  }
			});
		});
	}

	function dialog_close(){
		global.dialog.close()
	}
</script>